package com.atguigu.common.forest.controller;

import com.atguigu.common.forest.client.AmapClient;
import com.atguigu.common.forest.client.JsonClient;
import com.atguigu.common.forest.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author Jungle
 * @create 2023-12-29 22:28
 */
@RequestMapping("/map")
@RestController
public class AmapController {
    // 注入接口实例
    @Autowired
    private  AmapClient amapClient;
    @Autowired
    private  JsonClient jsonClient;

    @GetMapping("/position")
    // 调用接口
    public Map getMap(@RequestParam("longitude") String longitude, @RequestParam("latitude") String latitude) {
        return amapClient.getLocation(longitude, latitude);
    }

    @PostMapping("/json")
    public String getJson(User user) {
        return jsonClient.registerUser(user);
    }
}
